String.prototype.toJSON = function(){
	return eval('('+this+')');
}
$.isJson = function(obj){
    var isjson = typeof(obj) == "object" && Object.prototype.toString.call(obj).toLowerCase() == "[object object]" && !obj.length;
    return isjson;
}

jQuery.fn.extend({
	toggleAttr:function(attr,oVal,nVal){
		if(arguments.length==2){
			if(this.attr(attr)==undefined){
				this.attr(attr,oVal);
			}else{
				this.removeAttr(attr);
			}
		}else if(arguments.length==3){
			if(this.attr(attr)==oVal){
				this.attr(attr,nVal);
			}else{
				this.attr(attr,oVal);
			}
		}
	}
});